package com.example.demo.rsa;


import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;

import java.nio.charset.StandardCharsets;

public class Test3 {


    public static void main(String[] args) throws Exception {


        String privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" +
                "MIICXAIBAAKBgQCAWQ4eYPEvte+bS4KM1jWksKjR1+bHB4Lc8KL6WMNFFTpQaWie\n" +
                "Rb7/F7gbpRSnG/Xhg6VDsdpSGaGOJmCk7hN2mdWRl49dPTuNNC+PK8lK5nvmkhYz\n" +
                "I1u78y9Pym7RSPX+NGGc0yrqytbRzwKPIHcTlKQGUIUw6zr2sk1m1LzdmwIDAQAB\n" +
                "AoGAO6+uZig04TgdZj2WR4JyTdUtnPBnTNVMYQyy7fMLU/wMM0rhsQDEUoKoRord\n" +
                "cN0K2kXLPBDgc1+iBqYIOYrRl6KhYBGr/llNHhlCX4oRliZYFHRU+3z8dj0/5Ija\n" +
                "q/CJZWEA80jYDDUJ9QGXgROAaLiTl5c/8LpIOTrzQ5wWA/kCQQCdLNpp409IW13J\n" +
                "1LelsvDMDldTpgZX2PLqpwtHEj3R2qixhFW02HYheU8OfXXcVU8VHWHZeU+dXva2\n" +
                "EEnNDbcPAkEA0Qwc1QUzgEZF0qjI/Qs8utQDaMtqNLw85NUGz3ywq2alqroY3NOE\n" +
                "ke2zcOCZqkK+RACjr2eJ5Om4izLi286QtQJAHXLE7Wf4d88ekG05h2MyeJkLRZHq\n" +
                "yFTOlqZ7l3JUgNgeGTx5LmwMHhNze3yIM6MMMSGTLsLq5spfIReGLFQwgwJAaHBq\n" +
                "vyo4DrANFi/pKjLBBn4BrgtiZjJdId4j5ulewmMoBWGwJjMumlFtQsmTO/LYZ9UB\n" +
                "8hICXHFAF5s2p6ZNuQJBAI+cyQcPrxSoHn8rPg4CAHluLLqRxnK2jy7rexBCaHzU\n" +
                "ODKSstnaxGFL+NMIGn2GTce06QeUXlltpLPxxKecjRo=\n" +
                "-----END RSA PRIVATE KEY-----";


        String version = "X0YhaVtw2AIn5oR7NefeNNndLXIP9F0W5OY1cON3R23qJLC6vDRlzg4R5hiJxzCG1PmUmjTiYwFQmrMPnTk4zkC3fdQxIzaDvmLVlUgogcecUkeCtbLafXnILxd0QMtqvAPz1PB4eee0ahRRur1yMGt90FAulKl3EPYld0q5RbA=";


        privateKey = privateKey.replace("\n", "").replaceAll("-----BEGIN RSA PRIVATE KEY-----", "").replaceAll("-----END RSA PRIVATE KEY-----", "");
        RSA rsa = new RSA(privateKey, null);

        byte[] decrypt = rsa.decrypt(version.getBytes(StandardCharsets.UTF_8), KeyType.PrivateKey);

        String s = new String(decrypt, StandardCharsets.UTF_8);
        System.out.println(s);


    }


}
